Skip to content

fix(durable): record an actor stopped in the step that spawns it, or before it respawns, as ended - #272

Merged
reka18 merged 2 commits into
mainfrom
fix/durable-stopactor-actor-sets
Nov 25, 2026
Merged

reka18 merged 2 commits into
mainfrom
fix/durable-stopactor-actor-sets

Conversation

@reka18

@reka18 reka18 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What this does

#235 made durable skip spawning an actor whose state was already left in the same step. Two gaps remained. Both involve an explicit stopActor while the declaring state stays active, and both left the journal's actor sets out of step with the live Handle:

  • A spawn skipped by an explicit stop wasn't noted as attempted. The journal recorded the actor as unstarted, so every Recover spawned it fresh and ran its behavior, while the live Handle had no such actor. It's now recorded as ended. This covers a stop later in the step's own effects, and a stop from a parent Fire that an earlier spawn drove. It holds for Fire, Tick, RunService and Start.
  • A stop that arrived before its target respawned was lost. During Recover's respawn, a failed respawn's onError could stop another actor before that actor respawned. The stop did nothing, and the actor kept running. Stops noted during the respawn batch now apply to the actors the batch respawned.

The fix also separates an explicit stop from a state being left. left() now reads the states a parent Fire's trace exited, rather than every StopActor. So an explicit stop followed by re-entering the same state later in one step still spawns the new activation. Only a Fire that succeeded counts its exits: a Fire that failed partway, such as in an exit action, left its states active.

All of it is in durable/runner.go, with no new API and no journal format change.

Tests

durable/actor_stop_sets_test.go:

  • TestRecover_ASpawnTheSameStepStops_IsEndedNotUnstarted, for Fire, Tick and RunService;
  • TestRecover_ASpawnAParentFireStops_IsEndedNotUnstarted, for Fire and Start;
  • TestRecover_AStopBeforeItsTargetRespawns_EndsIt, with a control row where a live Fire stops the actor while it runs;
  • TestTick_AnExplicitStopThenAReentry_SpawnsTheNewActivation;
  • TestRecover_ASpawnAStateAFailedFireTriedToExit_Runs.

Every row compares the live Handle's actors with a recovered Handle's, with and without checkpoints. Each touch point is mutation-checked and fails its own rows.

Checks

  • mage check passes in every module (go1.27.4)
  • CHANGELOG entry

Closes #261

@reka18 reka18 added ready All ACR dimensions confirmed - clear to merge confirmed:correctness ACR clean: correctness confirmed:regression-safety ACR clean: regression-safety confirmed:concurrency-discipline ACR clean: concurrency-discipline confirmed:replay-determinism ACR clean: replay-determinism confirmed:api-compatibility ACR clean: api-compatibility confirmed:missed-context ACR clean: missed-context confirmed:human-readability ACR clean: human-readability confirmed:probes ACR: the probes lens's latest round found no blocker labels Nov 18, 2026
@reka18

reka18 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Review findings

The AI reviewers' pass over this change checked every review label. They found one real regression, which is fixed in the second commit:

  1. A failed parent Fire's exits counted as states left. The kernel records a state's exit before it runs the state's exit actions. When one of those actions fails, the Fire returns its error with the trace still naming that state, while the configuration stays where it was. The first commit read those exits as states left, so a later spawn in the same step for a still-active state was skipped and recorded as ended. Now only a Fire that succeeded counts its exits. TestRecover_ASpawnAStateAFailedFireTriedToExit_Runs covers it, and it fails without the guard.

Two candidates were refuted:

  • A lite trace could hide exits. Every path that records a parent Fire runs with full trace: Start casts, and Recover and the stateless Fire restore, with unbounded history.
  • Tick takes the collector before its absorb. The collector is always empty at that point, because the host drives actors only inside steps.

@reka18

reka18 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Decisions for Temple to ratify

I made these calls in this PR. Each is a suggestion for you to confirm or change.

  1. An actor explicitly stopped in the step that spawns it never runs, as long as its state stays active, and it's recorded as ended. This keeps fix(durable): dispatch effects from Start, Tick and RunService #235's skip. Before fix(durable): dispatch effects from Start, Tick and RunService #235, the spawn ran and stopped at once, so its start messages went out once.
  2. An explicit stop is not a state being left. If an actor is stopped and its state is then re-entered later in the same step, the new activation spawns. The issue didn't name this case. I fixed it here, with a test, because the fix changes the same lines.
  3. Stops noted during Recover's respawn batch apply to the actors that batch respawned. The journal holds the stop, so both the recovering Handle and a later Recover end the actor.
  4. No journal format change. durable is greenfield, so the corrected actor sets apply to every journal.

@reka18
reka18 force-pushed the fix/durable-actor-driven-effects branch from 685a0a4 to 1e2f238 Compare November 24, 2026 19:40
Base automatically changed from fix/durable-actor-driven-effects to main November 25, 2026 15:37
…before it respawns, as ended

An explicit stopActor while the actor's declaring state stays active - one a
step's own effects hold later than the spawn, as the OnDone of a compound the
step completes, or one a parent Fire an earlier spawn drove - skipped the
spawn but noted nothing, not even an attempt, so the journal recorded the
actor unstarted and a Recover spawned it fresh, running its behavior a second
time. The same held for a stop a parent Fire noted while Recover respawned a
batch of running actors, before its target respawned: the stop found nothing
running and did nothing, though the journal held it, so both the recovering
Handle and a later Recover ran the actor the live run had ended. And an
explicit StopActor counted as the actor's state being left, so a stop followed
by a re-entry of the same state later in the same step skipped the new
activation's spawn too, and the actor never ran though its state was active.

- durable: absorbActors notes every spawn it skips as attempted and stopped,
  so actorSets counts the actor ended and the journal records it ended rather
  than unstarted, and a Recover spawns none of them. An actor that is
  explicitly stopped in the step that spawns it, while its state stays active,
  never runs its behavior.
- durable: a parent Fire's stops are noted by actor on the collector, and left
  now reports the states a Fire's trace says it exited, so an explicit
  StopActor no longer lefts the state. A StopActor the step absorbs supersedes
  the Fire's mark, so a stop followed by a re-entry of the same state later in
  the same step doesn't skip the new activation's spawn.
- durable: respawn applies the stops a batch's Fires noted, before their
  target's respawn, to the actors the batch respawned, so the recovering
  Handle ends them and the journal records them ended, and a later Recover
  ends them too.

Closes #261.

Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
@reka18
reka18 force-pushed the fix/durable-stopactor-actor-sets branch from 78bcfe1 to 7cd223c Compare November 25, 2026 20:42
@reka18
reka18 marked this pull request as ready for review November 25, 2026 20:55
@reka18
reka18 merged commit 7852800 into main Nov 25, 2026
123 checks passed
@reka18
reka18 deleted the fix/durable-stopactor-actor-sets branch November 25, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

confirmed:api-compatibility ACR clean: api-compatibility confirmed:concurrency-discipline ACR clean: concurrency-discipline confirmed:correctness ACR clean: correctness confirmed:human-readability ACR clean: human-readability confirmed:missed-context ACR clean: missed-context confirmed:probes ACR: the probes lens's latest round found no blocker confirmed:regression-safety ACR clean: regression-safety confirmed:replay-determinism ACR clean: replay-determinism ready All ACR dimensions confirmed - clear to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

durable: an explicit stopActor during a step or a respawn can leave the actor sets out of step

2 participants